package com.app.controller;


import com.app.aspect.AutoLog;
import com.app.model.Article;
import com.app.service.IArticleService;
import com.app.util.Result;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 文章内容表 前端控制器
 * </p>
 *
 * @author yoominic
 * @since 2025-01-21
 */
@RestController
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private IArticleService articleService;
    /**
     * 第页
     *
     * @param page  第页
     * @param size  尺寸
     * @param title 标题
     * @param cid   cid
     */
    @GetMapping("page")
    @AutoLog("查询文章列表")
    public Result page(@RequestParam(value = "page",defaultValue = "1") Integer page,
                     @RequestParam(value = "size",defaultValue = "10") Integer size,
                     @RequestParam(value = "title",required = false) String title,
                     @RequestParam(value = "cid",required = false) Integer cid)
    {

        Page<Article> articlePage=new Page<>(page,size);
        return Result.success(this.articleService.adminPage(articlePage,title,cid));
    }
}

